<?php	
	define("X_PATH", ABS_PATH . 'xml/');
	
	
	function loadDom($filename) {
		$dom = new DOMDocument;
		$dom->Load($filename);
		return $dom;
	}
	
	$dvd_dom = loadDom(ABS_PATH . 'dvd.xml');
	$dvd_xpath = new DOMXPath($dvd_dom);
	
	$dvd_dom->validate(); // obligatoire pour pouvir utiliser getElementById
	
	function checkDTD($dom) {
		if ($dom->validate())
			echo "document xml valide!<br/>";
		echo '<a href="../dvd.xml">dvd.xml</a>';
	}
	
	function transform($xml_dom, $xsl_dom) {
		$xslt = new XSLTProcessor();
		$xslt->importStylesheet($xsl_dom);
		return $xslt->transformToDoc($xml_dom);
	}
	
	function saveDVDs() {
		global $dvd_dom;
		copy(ABS_PATH . 'dvd.xml', ABS_PATH . 'old_dvd.xml');
		$dvd_dom->save(ABS_PATH . 'dvd.xml');
		
	}
	
	/*
	$nbdvd = $xpath->evaluate('count(//dvd)');
	$entries = $xpath->query('//dvd/title');
	
	foreach ($entries as $entry)
		echo $entry->nodeValue . '<br/>';
	*/
	
?>
